package com.topsun.framework.common.core.util;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
 * Created by yixin on .
 */
@Slf4j
public class HttpsUtil {

    public static String get(String urlPath) {
        return get(urlPath, null);
    }

    public static String get(String urlPath, Map<String, Object> params) {
        return HttpUtil.get(urlPath, params);
    }

    public static JSONObject getJson(String urlPath) {
        return getJson(urlPath, null);
    }

    public static JSONObject getJson(String urlPath, Map<String, Object> params) {
        String responseBody = get(urlPath, params);
        return JsonUtil.parseJsonObject(responseBody);
    }


    public static String post(String urlPath) {
        return post(urlPath, null);
    }

    public static String post(String urlPath, Map<String, Object> params) {
        return HttpUtil.post(urlPath, params);
    }

    public static JSONObject postJson(String urlPath) {
        return postJson(urlPath, null);
    }

    public static JSONObject postJson(String urlPath, Map<String, Object> params) {
        String responseBody = get(urlPath, params);
        return JsonUtil.parseJsonObject(responseBody);
    }



}
